#ifndef _HAL_GPIO_H_
#define _HAL_GPIO_H_

/*******************************************************************
 *
 * Copyright (C), 2021-2022, Letstrong, All rights reserved.
 *
 * Author      : 
 * Create Time : 2020-12-12
 * Version     : v0.1
 * Description : 
 *******************************************************************/
 
/*----------------------------Head file----------------------------*/
#include "gpio.h"
#include "user_config.h"

/*----------------------------macro file---------------------------*/

#define hal_gpio_write				gpio_set
#define hal_gpio_read				gpio_get_input

#define hal_gpio_output_cfg(pin_num, pull)		gpio_config(pin_num, OUTPUT, (Pull_Type)pull)
#define hal_gpio_input_cfg(pin_num, pull)		gpio_config(pin_num, INPUT, (Pull_Type)pull)
#define hal_gpio_float_cfg(pin_num, pull)		gpio_config(pin_num, FLOAT, (Pull_Type)pull)
#define hal_gpio_hires_cfg(pin_num, pull)		gpio_config(pin_num, HIRESI, (Pull_Type)pull)

#define hal_gpio_int_master_enable()			(REG_AHB0_ICU_INT_ENABLE |= INT_STATUS_GPIO_bit)
#define hal_gpio_int_master_disable()			(REG_AHB0_ICU_INT_ENABLE &= (~INT_STATUS_GPIO_bit))

/*----------------------------type define--------------------------*/
typedef void (*hal_gpio_int_evt_cb)(uint8_t pin_num);

typedef enum
{
    ACTIVE_LOW = 0,
    ACTIVE_HIGH,
} hal_gpio_active_t;

typedef enum
{
    PULL_UP = 0,
    PULL_DOWN,
    PULL_NULL,
} hal_gpio_pull_t;

typedef enum {
	RAISING_EDGE = 0,
	FALLING_EDGE,
} hal_gpio_int_edge_t;

/*----------------------------var define---------------------------*/

/*-------------------------func declaration------------------------*/
extern void hal_gpio_init(void);
extern void hal_gpio_int_enable(uint8_t pin_num, hal_gpio_int_edge_t edge, hal_gpio_int_evt_cb evt_cb);
extern void hal_gpio_int_disable(uint8_t pin_num);
extern void hal_gpio_int_status_clear(uint8_t pin_num);

/*-----------------------------------------------------------------*/

#endif
